﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OpGen.Compiler.Parser
{
    /// <summary>
    /// Stellt eine Liste mit Include-Dateien dar
    /// </summary>
    [Serializable]
    public class IncludeFileCollection : IEnumerable<IncludeFile>
    {
        private List<IncludeFile> _list = new List<IncludeFile>();

        /// <summary>
        /// Fügt der Liste ein Element hinzu
        /// </summary>
        /// <param name="element"></param>
        public void Add(IncludeFile element)
        {
            _list.Add(element);
        }

        /// <summary>
        /// Entfernt ein Element aus der Liste
        /// </summary>
        /// <param name="element"></param>
        public void Remove(IncludeFile element)
        {
            _list.Remove(element);
        }

        /// <summary>
        /// Liefert ein Element anhand des Index
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public IncludeFile this[int index]
        {
            get { return _list[index]; }
            set { _list[index] = value; }
        }

        /// <summary>
        /// Liefert die Anzahl der Elemente in der Liste
        /// </summary>
        public int Count
        {
            get { return _list.Count; }
        }

        /// <summary>
        /// Löscht die gesamte Liste
        /// </summary>
        public void Clear()
        {
            _list.Clear();
        }

        /// <summary>
        /// Gibt an ob ein Element bereits in der Liste vorhanden ist
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public bool Contains(IncludeFile element)
        {
            return _list.Contains(element);
        }

        #region IEnumerable<IncludeFile> Member
        /// <summary>
        /// Wird für ForEach verwendet
        /// </summary>
        /// <returns></returns>
        public IEnumerator<IncludeFile> GetEnumerator()
        {
            return _list.GetEnumerator();
        }

        /// <summary>
        /// Wird für ForEach verwendet
        /// </summary>
        /// <returns></returns>
        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return _list.GetEnumerator();
        }

        #endregion
    }
}
